//
//  BOCNetworkImageManager.h
//  BOCImageTools
//
//  Created by LeungChaos on 16/5/11.
//  Copyright © 2016年 liang. All rights reserved.
//

#import "BOCHeader.h"
#import <UIKit/UIKit.h>

// URL路径转成md5字符串
NSString * objectKeyWithUrl(NSURL *url);
// 返回主队列
void dispatch_mainQueue_safely_sync(void(^block)());

@class BOCImageDownloader;
@class BOCImageDownloadTask;

@interface BOCNetworkImageManager : NSObject

/**
 *  返回一个单例的图片下载管理者
 */
+ (instancetype)sharedManager;

/**
 *  获取BOC缓存图片的缓存文件夹的大小
 */
- (void)imageCacheFileSizeBlock:(void(^)(long long size))block;

/**
 *  清除所有图片缓存
 */
- (void)clearAllImageCacheWithState:(void(^)(BOOL isSeccess))state;

/**
 *  只删除过期和超出缓存容量的文件
 *
 *  @param completion 完成时回调
 */
- (void)cleanExpiredFileCompletion:(void(^)())completion;
/**
 *  让url成为key 返回一张图片
 */
- (UIImage *)imageForURLkey:(NSURL *)key;

- (NSString *)cacheImageFilePathWithKey:(NSURL *)key;


/**
 *  下载图片
 *
 *  @param url          图片的路径
 *  @param seccessBlock 下载成功时回调
 *  @param errorBlock   下载失败时回调
 */
- (BOCImageDownloadTask *)downImageWithURL:(NSURL *)url seccess:(BOCDownloadImageSeccessBlock)seccessBlock fail:(BOCDownloadImageFailErrorBlock)errorBlock;

/**
 *  下载图片 监听下载进度
 *
 *  @param url              图片的路径
 *  @param progressBlock    监听下载进度
 *  @param seccessBlock     下载成功时回调
 *  @param errorBlock       下载失败时回调
 */
- (BOCImageDownloadTask *)downImageWithURL:(NSURL *)url progress:(BOCProgressHandlerProgressBlock)progressBlock seccess:(BOCDownloadImageSeccessBlock)seccessBlock fail:(BOCDownloadImageFailErrorBlock)errorBlock;

@property (nonatomic, readonly, strong) BOCImageCacher *imageCacher;

@property (nonatomic, readonly, strong) BOCImageDownloader *downloader;


@end
